package com.rfsp.mcp.controller.base;

import com.rfsp.mcp.pojo.vo.BargainVO;
import com.rfsp.mcp.pojo.vo.HospitalVO;
import com.rfsp.mcp.service.BargainService;
import com.rfsp.mcp.service.HospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller("BaseBargainController")
@RequestMapping("/base/bargain")
public class BaseBargainController extends BaseController {

    @Autowired
    BargainService service;

    @Autowired
    HospitalService hospitalService;

    @GetMapping("/detail")
    public String detail(ModelMap model,Long id,String aid) {
        BargainVO vo=service.getById(id);
        if(!vo.getAid().equals(aid)){
            return this.errorAidNotMatch(model);
        }
        service.combo(vo);

        HospitalVO miOrg=hospitalService.getById(vo.getMiOrgId());
        vo.setMiOrgName(miOrg.getOrgName());

        model.put("vo",vo);
        return "base/bargain/detail";
    }

}